<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Controller;

use App\Service\ExampleQueueService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\RequestMapping;

class TestController extends AbstractController
{
    #[Inject] protected ExampleQueueService $exampleQueueService;

    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();
        return [
            'method' => $method,
            'message' => "Hello {$user}.".time(),
        ];
    }



    #[RequestMapping('uploadImageTest',methods: 'get,post')]
    public function uploadImageTest(): object{
        $this->exampleQueueService->push([
            'group@hyperf.io',
            'https://doc.hyperf.io',
            'https://www.hyperf.io',
        ],60);
        return $this->reMsg->re(1);
    }


    #[RequestMapping('uploadFileToHost',methods: 'get,post')]
    public function uploadFileToHost():object
    {
        try{
            return $this->upload->uploadImageToHost('user','image');
        }catch (\Exception $exception){
            return $this->diyError->errorJson($exception);
        }
    }
}
